package com.zs.lib_base.utils

import android.animation.AnimatorSet
import android.animation.ObjectAnimator
import android.annotation.SuppressLint
import android.view.View


/**
 * descrition:缩放动画
 */
@SuppressLint("ObjectAnimatorBinding")
fun scalView(view:View?=null, numberView:View?=null){
    if(view==null || numberView==null ) return
    val scaleY: ObjectAnimator = ObjectAnimator.ofFloat(view, "scaleY", 1f, 1.2f,1f)
    val scaleX: ObjectAnimator = ObjectAnimator.ofFloat(view, "scaleX", 1f, 1.2f,1f)

    val animatorSet = AnimatorSet()
    animatorSet.duration = 300
    animatorSet.play(scaleY).with(scaleX)
    animatorSet.start()

    //透明度动画
    val alpha: ObjectAnimator = ObjectAnimator.ofFloat(numberView, "alpha", 0f, 1f,0f)
    alpha.duration = 1000
    alpha.start()
}

@SuppressLint("ObjectAnimatorBinding")
fun scalViewList(view:View?=null, numberView:View?=null){
    if(view==null || numberView==null ) return
    val scaleY: ObjectAnimator = ObjectAnimator.ofFloat(view, "scaleY", 1f, 1.1f,1f)
    val scaleX: ObjectAnimator = ObjectAnimator.ofFloat(view, "scaleX", 1f, 1.1f,1f)

    val animatorSet = AnimatorSet()
    animatorSet.duration = 300
    animatorSet.play(scaleY).with(scaleX)
    animatorSet.start()

    //透明度动画
    val alpha: ObjectAnimator = ObjectAnimator.ofFloat(numberView, "alpha", 0f, 1f,0f)
    alpha.duration = 1000
    alpha.start()
}